home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: Philippe Verdy <100105.3120@compuserve.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Bletcherous kludge!
- Date: 1 Apr 1996 23:29:31 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4jposr$lhj@dub-news-svc-6.compuserve.com>
- NNTP-Posting-Host: ad15-078.compuserve.com
-
- jlilley@ix.netcom.com (John Lilley) s'Θcrit :
- > In article <4jhr2b$9ou@portal.gmu.edu>, rraffer1@osf1.gmu.edu says...
- > >
- > >I am trying to get the contents of a custom String class to be converted
- > >into numeric data, ie float. The String class consists of :
- > >
- > >Buffer: a null-terminated array of char
- >
- > C++ still has atof(). There is probably a more elegant, C++ correct approach
- > that I don't know of.
- >
- > john lilley
- >
- The double atof(char*) function (from <stdlib.h>) is elegant
- for C++: it is perfectly defined, type-safe, and has no side
- effect on its arguments and in its environment. So it is
- a perfect conversion method which applies on a (char *) object.
-
- We cannot say it about sscanf(string, "%lf", &doublevar)
- because type-safety on the third argument and later is not
- guaranteed, this is why iostreams where created !
-
- Even though most of <stdlib.h> function were commonly used in
- C, does not mean you cannot use them safely in C++ !
-
- Don't discriminate !
-